<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>Fengqin-swoole-ws测试</h1>
    <script>
        var wsUrl = 'ws://39.98.144.29:6065';

        var webSocket = new WebSocket(wsUrl);

        //实例化对象onOpen 属性
        webSocket.onopen = function (evt) {
            webSocket.send("hello_Fen_Qin_SWOOLE");
            console.log("connected-swoole-success");
        }
        //实例化对象onmessage
        webSocket.onmessage = function (evt) {
            console.log('ws-server-request-data:'+ evt.data);
        }
        
        //实例化close事件
        webSocket.onclose = function (evt) {
            console.log('colse-swoole');
        }
        //onerror
        webSocket.onerror = function (evt,e) {
            console.log("error:"+evt.data)
        }
    </script>
</body>
</html>